package com.mine.crawler.beans;

import java.util.ArrayList;
import java.util.List;

public class MySqlDBCategoryNodeLogical
{
	private String category_name;
	private String complete_cat_name;
	private int category_id;
	private List<MySqlDBCategoryNodeLogical> children = new ArrayList<MySqlDBCategoryNodeLogical> ();
	private List<String> related = new ArrayList<String>();
	private List<String> altLangList = new ArrayList<String>();
	
	public MySqlDBCategoryNodeLogical(String local_catName)
	{
		if(local_catName.startsWith("/"))
			local_catName = local_catName.substring(1);
		complete_cat_name = local_catName;
		if(complete_cat_name!=null)
		{
			String[] tempStrArr = complete_cat_name.split("/");
			category_name = tempStrArr[(tempStrArr.length)-1];
		}
		else category_name = local_catName;
	}

	public MySqlDBCategoryNodeLogical(String local_catName, int local_catId)
	{
		complete_cat_name = local_catName;
		category_id = local_catId;
	}
	
	public String getCategory_name()
	{
		return category_name;
	}
	public void setCategory_name(String categoryName)
	{
		category_name = categoryName;
	}
	public int getCategory_id()
	{
		return category_id;
	}
	public void setCategory_id(int categoryId)
	{
		category_id = categoryId;
	}

	public List<MySqlDBCategoryNodeLogical> getChildren()
	{
		return children;
	}

	public void setChildren(List<MySqlDBCategoryNodeLogical> local_children)
	{
		children.addAll(children);
		//this.children = children;
	}
	
	public void addChild(MySqlDBCategoryNodeLogical node)
	{
		children.add(node);
	}
	
	public List<String> getRelated()
	{
		return related;
	}

	public void setRelated(List<String> local_related )
	{
		related.addAll(local_related);
		//this.children = children;
	}
	
	public void addAltLangList(String node)
	{
		altLangList.add(node);
	}
	
	public List<String> getAltLangList()
	{
		return altLangList;
	}

	public void setAltLangList(List<String> local_related )
	{
		altLangList.addAll(local_related);
		//this.children = children;
	}
	
	public void addRelated(String node)
	{
		related.add(node);
	}

	public String getComplete_cat_name()
	{
		return complete_cat_name;
	}

	public void setComplete_cat_name(String completeCatName)
	{
		complete_cat_name = completeCatName;
	}

	public String toString()
	{
		return "complete_cat_name = " + complete_cat_name + 
			" category_name = "+  category_name + " cat_id = " + category_id;
	}
	
	public boolean equals(Object obj)
	{
		if(obj==null)
			return false;
		MySqlDBCategoryNodeLogical localNode = (MySqlDBCategoryNodeLogical) obj;
		if(this.getCategory_name().equalsIgnoreCase(localNode.getCategory_name()))
			//if(this.getComplete_cat_name().equalsIgnoreCase(localNode.getComplete_cat_name()))
				return true;
			//else
				//return false;
		else
			return false;
	}
}

